const { ccclass, property } = cc._decorator;

@ccclass
export default class NewClass extends cc.Component {

    onLoad() {
        var fsm = new StateMachine({
            init: 'solid',
            transitions: [
                { name: 'melt', from: 'solid', to: 'liquid' },
                { name: 'freeze', from: 'liquid', to: 'solid' },
                { name: 'vaporize', from: 'liquid', to: 'gas' },
                { name: 'condense', from: 'gas', to: 'liquid' }
            ],
            methods: {
                onMelt: function () { console.log('I melted') },
                onFreeze: function () { console.log('I froze') },
                onVaporize: function () { console.log('I vaporized') },
                onCondense: function () { console.log('I condensed') }
            }
        });
        console.error("", fsm, fsm.transitions(), fsm.allStates(), fsm.allTransitions(), fsm.state);

        fsm.melt()
    }

}